This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
[Enhancement] Refactor command_execution_time segment #1215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a back-port of #1214 on the
next
branch.I wanted to add an "s" after the seconds display, in the case that the execution time was under a minute, to make it clearer what units were being displayed, when there were no colons.
In the process of investigating this modification, I noticed that the code for formatting either whole or partial seconds (depending on the POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION variable) seemed unnecessarily complex. By eliminating the pre-declaration of the number type and replacing it with a printf statement to format on the fly, I was able to squash a three-way if/elif/else control structure into a single line.
I also noticed that all this formatting was being done every time, regardless of whether the execution time actually exceeded the threshold, so I moved that logic to the front of the module, so that none of those computations happen if nothing will be displayed anyway.